package yinxiang;

import com.evernote.edam.error.EDAMNotFoundException;
import com.evernote.edam.error.EDAMSystemException;
import com.evernote.edam.error.EDAMUserException;
import com.evernote.edam.notestore.NoteFilter;
import com.evernote.edam.notestore.NoteList;
import com.evernote.edam.type.Note;
import com.evernote.edam.type.NoteSortOrder;
import com.evernote.edam.type.Notebook;
import com.evernote.thrift.TException;

import java.util.List;

public class Api {

    /****
     * 获取所有笔记本
     */
    public List<Notebook> notebooks() throws Exception {
        List<Notebook> notebooks = Config.getNoteStore().listNotebooks();
        return notebooks;
    }

    /****
     * 根据笔记本id获取该笔记本下的笔记
     * @param noteBookId
     * @return
     */
    public List<Note> notes(String noteBookId) throws TException, EDAMNotFoundException, EDAMSystemException, EDAMUserException {
        NoteFilter filter = new NoteFilter();
        filter.setNotebookGuid(noteBookId);
        filter.setOrder(NoteSortOrder.CREATED.getValue());
        filter.setAscending(true);

        NoteList noteList = Config.getNoteStore().findNotes(filter, 0, 200);
        List<Note> notes = noteList.getNotes();
        return notes;
    }

    /***
     * 获取单个日记
     * @param noteId
     * @param isContent
     * @return
     * @throws Exception
     */
    public Note note(String noteId,boolean isContent) throws Exception {
        Note fullNote = Config.getNoteStore().getNote(noteId, isContent, true, false,
                false);
        return fullNote;
    }

}
